from django.db import models
from django.contrib.auth.models import AbstractUser

# 收银员表（继承Django内置用户表）
class Cashier(AbstractUser):
    phone = models.CharField(max_length=11, unique=True, verbose_name="手机号")
    is_active = models.BooleanField(default=True, verbose_name="是否启用")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")

    class Meta:
        verbose_name = "收银员"
        verbose_name_plural = verbose_name
        db_table = "user_cashier"  # 数据库表名

# 网购客户表
class Customer(models.Model):
    username = models.CharField(max_length=50, unique=True, verbose_name="用户名")
    phone = models.CharField(max_length=11, unique=True, verbose_name="手机号")
    password = models.CharField(max_length=128, verbose_name="密码")  # 存储加密后密码
    address = models.TextField(null=True, blank=True, verbose_name="收货地址")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="注册时间")

    class Meta:
        verbose_name = "网购客户"
        verbose_name_plural = verbose_name
        db_table = "user_customer"
